#删除原容器

echo "begin stop and delete old portainer......"
docker stop portainer-cqj && docker rm portainer-cqj
echo "=======================rm over=============================="

# pull portainer images
echo "=======================start pull portainer images=============================="
docker pull 6053537/portainer-ce
echo "=======================pull end.=============================="

# check path
data_path="/home/docker/portainer/data"
if [[ ! -d "$data_path" ]]; then
    echo "data_path not exsits,create now."
    mkdir -p ${data_path}
else
    echo "data_path exsits,do not create."
fi

#build new portainer container
echo "=======================start build portainer container=============================="
docker run -d \
-p 9000:9000 \
--ip 172.20.1.14 \
--network=bridge-chen \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/docker/portainer/data:/data \
--privileged=true \
--name portainer-cqj \
--restart=always \
6053537/portainer-ce:latest
echo "=======================build end.=============================="
